/**
 * Created by jimshi0912 on 15/11/2.
 */
(function () {
    angular.module('my-tabs.directives')
        .directive('categoryThumb', categoryThumb);

    function categoryThumb() {
        return {
            restrict: 'E',
            scope: {
                category: '='
            },
            templateUrl: 'views/explore/category-thumb.html',
            controller: ['$scope', '$state', 'md5', 'appService', '$sce',
                function ($scope, $state, md5, appService, $sce) {
                    $scope.openCategory = function () {
                        var frameId = md5.createHash($scope.category.name || '');
                        appService.putFrame({
                            id: frameId,
                            name: $scope.category.name,
                            link: $sce.trustAsResourceUrl($scope.category.name)
                        });
                        $state.go('main.frame', {frameId: frameId});
                    };
                }],
            link: function (scope, element, attrs) {

            }
        }
    }
})();
